package com.catchdays.main;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.catchdays.db.model.CatchDaysModel;

public class CatchDaysListAdapter extends BaseAdapter {
	private Context context;

	private List<CatchDaysModel> catchDaysList = new ArrayList<CatchDaysModel>();

	public CatchDaysListAdapter(Context context) {
		this.context = context;
	}

	public void setCatchDaysList(List<CatchDaysModel> catchDaysList) {
		this.catchDaysList = catchDaysList;
	}

	@Override
	public int getCount() {
		return catchDaysList.size();
	}

	@Override
	public Object getItem(int position) {
		return catchDaysList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		CatchDaysListItemView itemView = null;

		if (convertView == null) {
			itemView = CatchDaysListItemView_.build(context);
		} else {
			itemView = (CatchDaysListItemView) convertView;
		}

		itemView.setModel(catchDaysList.get(position));

		return itemView;
	}

}
